<?php
session_start();
include 'dbconfig.php'; 

mysql_select_db($db, $con);
if (isset($_SESSION['uid'])) {
	$uid = $_SESSION['uid'];

	$query = "SELECT courses.mod, courses.grade, course_instances.cid, course_instances.hash FROM courses JOIN course_instances ON (courses.hash = course_instances.hash) WHERE uid = '".$uid."'";
	$result = mysql_query($query);

	while ($row = mysql_fetch_array($result)) {
		echo "courseList['".$row['cid']."'] = {hash: '".$row['hash']."',mod: '".$row['mod']."', grade: ".$row['grade']."};\n";
	}
	
	
	$query = "SELECT * FROM exams WHERE uid = '".$uid."'";
	$result = mysql_query($query);
	
	while ($row = mysql_fetch_array($result)) {
		echo "examList['".$row['mid']."'] = {oral: ".($row['oral']?"true":"false").", grade: ".$row['grade']."};\n";
	}


}
?>